<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>星辰诞愿 - 生日快乐</title>
    <style>
        /* Birthday Theme Styles */
        body {
            margin: 0;
            padding: 0;
            font-family: 'Comic Sans MS', cursive, sans-serif;
            background: linear-gradient(135deg, #fff5f5 0%, #fff0f5 100%);
            min-height: 100vh;
        }
        .nav {
            display: flex;
            align-items: center;
            padding: 15px 30px;
            background: rgba(255,255,255,0.95);
            box-shadow: 0 2px 15px rgba(210, 51, 105, 0.1);
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
            border-bottom: 3px solid #ff8e9e;
        }
        .nav img {
            height: 50px;
            margin-right: 15px;
        }
        .blog-title {
            font-size: 24px;
            font-weight: bold;
            color: #d23369;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
            position: absolute;
            left: 100px;
        }
        .nav-links {
            display: flex;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }
        .nav-span {
            margin: 0 15px;
            color: #d23369;
            text-decoration: none;
            font-weight: bold;
            padding: 5px 10px;
            border-radius: 5px;
            transition: all 0.3s;
        }
        .nav-span:hover {
            background-color: #ffebee;
            color: #ff4081;
        }
        .space {
            flex-grow: 1;
        }
        .container {
            display: flex;
            padding-top: 90px;
            min-height: calc(100vh - 90px);
            box-sizing: border-box;
        }
        .left, .center, .right {
            padding: 20px;
            box-sizing: border-box;
        }
        .left {
            width: 25%;
            background: rgba(255,255,255,0.8);
            border-right: 2px dashed #ffb8c6;
            display: flex;
            flex-direction: column;
            height: calc(100vh - 130px);
        }
        .center {
            width: 50%;
            background: rgba(255,255,255,0.9);
            height: calc(100vh - 130px);
            overflow-y: auto;
        }
        .right {
            width: 25%;
            background: rgba(255,255,255,0.8);
            border-left: 2px dashed #ffb8c6;
            height: calc(100vh - 130px);
            overflow-y: auto;
        }
        .card {
            background: white;
            border-radius: 15px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 5px 15px rgba(210, 51, 105, 0.1);
            border: 1px solid #ffd6de;
            position: relative;
        }
        .card:before {
            content: "🎀";
            position: absolute;
            top: -10px;
            left: -10px;
            font-size: 20px;
        }
        .user-info {
            text-align: center;
        }
        .user-info img {
            width: 100px;
            height: 100px;
            border-radius: 25%;
            border: 3px solid #ff8e9e;
            object-fit: cover;
            margin-bottom: 15px;
        }
        .user-info h3 {
            color: #d23369;
            margin: 10px 0;
        }
        .user-stats {
            display: flex;
            justify-content: space-around;
            margin: 10px 0;
        }
        .stat-item {
            text-align: center;
        }
        .stat-value {
            font-weight: bold;
            color: #d23369;
        }
        .stat-label {
            font-size: 12px;
            color: #666;
        }
        .user-info p {
            color: #666;
            margin: 5px 0;
        }
        .developer-info {
            text-align: center;
        }
        .developer-info h3 {
            color: #d23369;
            border-bottom: 2px dotted #ffb8c6;
            padding-bottom: 10px;
        }
        .developer-info p {
            color: #666;
            line-height: 1.6;
            margin: 8px 0;
        }
        .copyright {
            font-size: 12px;
            color: #999;
            margin-top: 15px;
        }
        .message-box {
            margin-top: auto;
            position: sticky;
            bottom: 20px;
            z-index: 100;
        }
        #blessing-content {
            width: 100%;
            padding: 10px;
            border: 2px solid #ffb8c6;
            border-radius: 8px;
            min-height: 80px;
            margin-bottom: 10px;
            resize: none;
            box-sizing: border-box;
        }
        .send-button {
            width: 100%;
            padding: 10px;
            background: linear-gradient(to right, #ff6b88, #ff8e53);
            color: white;
            border: none;
            border-radius: 8px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
        }
        .send-button:hover {
            background: linear-gradient(to right, #ff8e53, #ff6b88);
        }
        /* 新增的样式 - 从JS动态拼接转移过来 */
        .today-star {
            background: linear-gradient(to right, #ffb8c6, #ffd3b6);
            padding: 15px;
            border-radius: 10px;
            margin-bottom: 20px;
            text-align: center;
            border: 2px dashed #ff6b88;
        }
        .birthday-theme {
            text-align: center;
            color: #d23369;
            font-weight: bold;
        }
        .blessing-item {
            padding: 15px;
            margin-bottom: 15px;
            background: #fff9fa;
            border-radius: 10px;
            border-left: 5px solid #ff8e9e;
            position: relative;
        }
        .blessing-owner {
            font-weight: bold;
            color: #d23369;
            margin-bottom: 5px;
        }
        .blessing-content {
            color: #555;
            line-height: 1.5;
            margin-bottom: 10px;
        }
        .blessing-time {
            color: #999;
            font-size: 12px;
        }
        /* 寿星列表新增样式 */
        .birthday-star-title {
            color: #d23369;
            margin: 0 0 10px 0;
        }
        .birthday-star-container {
            display: flex;
            align-items: center;
            gap: 20px;
            padding: 10px;
        }
        .birthday-star-avatar {
            width: 120px;
            height: 120px;
            border-radius: 25%;
            border: 3px solid #ff8e9e;
            object-fit: cover;
        }
        .birthday-star-info {
            display: flex;
            flex-direction: column;
            justify-content: center;
            gap: 10px;
            text-align: left;
            height: 100%;
        }
        .birthday-star-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .birthday-star-label {
            font-size: 14px;
            color: #666;
        }
        .birthday-star-name {
            font-size: 18px;
            font-weight: bold;
            color: #d23369;
        }
        .birthday-star-role {
            font-size: 16px;
            font-weight: bold;
            color: #d23369;
        }
        .birthday-star-count {
            font-size: 16px;
            font-weight: bold;
            color: #d23369;
        }
    </style>
</head>
<body>
    <div class="nav">
        <img src="pic/cat.jpg" alt="小猫" title="小公主生日快乐">
        <span class="blog-title">星辰诞愿 - 生日快乐</span>
        <div class="nav-links">
            <a class="nav-span" href="login.html">登录页</a>
            <a class="nav-span" href="user_list.html">用户列表</a>
            <a class="nav-span" href="notice.html">公告</a>
            <a class="nav-span" href="bless_manage.html">管理祝福语</a>
            <a class="nav-span" href="user_modify.html">修改信息</a>
        </div>
        <div class="space"></div>
    </div>
    <div class="container">
        <div class="left">
            <div class="card user-info">
                <img id="user-avatar" src="" alt="用户头像">
                <h3 id="userName"></h3>
                <input type="hidden" id="id" value="1">
                <p id="birthday" style="font-size: 20px;color: green"></p>
                <div class="user-stats">
                    <div class="stat-item">
                        <div class="stat-value" id="user-role"></div>
                        <div class="stat-label">身份</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value" id="message-count"></div>
                        <div class="stat-label">祝福数</div>
                    </div>
                </div>
            </div>
            <div class="card message-box">
                <h4 style="color: #d23369; text-align: center; margin-bottom: 10px;">🎂 发送生日祝福 🎂</h4>
                <label for="blessing-content"></label><textarea id="blessing-content" placeholder="写下你的祝福语..."></textarea>
                <button onclick="submitBlessing()" class="send-button">发送祝福</button>
            </div>
        </div>
        <div class="center">
            <div class="card">
                <div id="today-star" class="today-star">
                </div>
            </div>
            <h3 class="birthday-theme">生日祝福墙</h3>
            <div id="blessings-list">
            </div>
            <div class="pagination" style="display: flex; justify-content: center; margin-top: 20px; gap: 10px;">
                <button id="prev-page" style="background: #ffb8c6; color: white; border: none; padding: 8px 15px; border-radius: 20px; cursor: pointer;">上一页</button>
                <div id="page-info" style="display: flex; align-items: center; color: #d23369; font-weight: bold;"></div>
                <button id="next-page" style="background: #ffb8c6; color: white; border: none; padding: 8px 15px; border-radius: 20px; cursor: pointer;">下一页</button>
            </div>
        </div>
        <div class="right">
            <div class="card developer-info">
                <img id="user-develop" src="pic/logo.png" title="小公主生日快乐" alt="开发者logo" width="320">
                <h3>星辰诞愿系统</h3>
                <p>✨ 生日祝福专属平台 ✨</p>
                <p>版本: Linhan002 生日特别版</p>
                <p>开发者: 九转苍翎</p>
                <p>联系QQ: 3210728077</p>
                <p>邮箱: 3210728077@qq.com</p>
                <p class="birthday-theme">🎁 让祝福传递温暖 🎁</p>
                <p class="copyright">© 2025 星辰诞愿 版权所有</p>
            </div>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script src="js/common.js"></script>
    <script>
        //获取当前登录用户
        getUrl("user/getLoginUser");
        //寿星列表
        getIsBirthday("user/isBirthday");
        //提交祝福
        function submitBlessing() {
            const content = $("#blessing-content").val().trim();
            if (!content) {
                alert("请输入祝福语");
                return;
            }
            $.ajax({
                type: "post",
                url: "/bless/add",
                contentType:"application/json",
                data: JSON.stringify({
                    content: content
                }),
                success: function(result) {
                    if (result.code === "SUCCESS") {
                        alert("祝福发送成功！");
                        $("#blessing-content").val("");
                        loadBlessings();
                    }else {
                        alert(result.errorMessage);
                    }
                },
                error: function(error) {
                    if (error.status === 401) {
                        location.href = "login.html";
                    } else {
                        alert("网络错误，请稍后重试");
                    }
                }
            });
        }
        //当前页码
        let currentPage = 1;
        const pageSize = 10;
        function loadBlessings(page = 1) {
            currentPage = page;
            $.ajax({
                type: "get",
                url: '/bless/getBlessInfoList?page=' + currentPage + '&size=' + pageSize,
                success: function(result) {
                    if (result.code === "SUCCESS" && result.data != null) {
                        let blessInfoList = result.data;
                        let finalHtml = '';
                        let total = result.page;
                        for(let blessInfo of blessInfoList) {
                            finalHtml += `
                                <div class="blessing-item">
                                    <div class="blessing-owner">
                                        ${blessInfo.userName}:
                                    </div>
                                    <div class="blessing-content">
                                        ${(blessInfo.content)}
                                    </div>
                                    <div style="display: flex; justify-content: space-between; align-items: center;">
                                        <div class="blessing-time">
                                            ${blessInfo.createTimeStatus}
                                        </div>
                                    </div>
                                </div>`;
                        }
                        $("#blessings-list").html(finalHtml);
                        updatePaginationInfo(total);
                    }
                },
                error: function (error) {
                    if (error != null && error.status === 401) {
                        location.href = "login.html";
                    }
                }
            });
        }
        // 更新分页信息
        function updatePaginationInfo(total) {
            const totalPages = Math.ceil(total / pageSize);
            $("#page-info").html(`第 ${currentPage} 页 / 共 ${totalPages} 页`);

            // 控制按钮状态,currentPage <= 1时不能翻上一页,currentPage >= totalPages不能翻下一页
            $("#prev-page").prop("disabled", currentPage <= 1);
            $("#next-page").prop("disabled", currentPage >= totalPages);
        }
        // 上一页按钮点击事件
        $("#prev-page").click(function() {
            loadBlessings(currentPage - 1);
        });
        // 下一页按钮点击事件
        $("#next-page").click(function() {
            loadBlessings(currentPage + 1);
        });
        loadBlessings(1);
    </script>
</body>
</html>